<template>
  <div>
    <el-container style="min-height: 100vh">
      <el-aside :width="sideWidth + 'px'" style="background-color: rgb(238, 241, 246);box-shadow: 2px 0 6px rgb(0 21 41 / 35%);">
        <Aside :is-collapse="isCollapse" :logo-text-show="logoTextShow"/>
      </el-aside>
      <el-container>
        <el-header style="border-bottom: 1px solid #ccc">
          <Header :collapse-btn-class="collapseBtnClass" :collapse="collapse" :user="user"/>
        </el-header>

        <el-main>
<!--          当前页面的子路由在此显示-->
          <router-view @refreshUser="getUser"/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>

import Aside from "@/components/Aside";
import Header from "@/components/Header";
export default {
  name: 'Manage',

  data(){
    return {
      collapseBtnClass: 'el-icon-s-fold',
      isCollapse: false,
      sideWidth: 210,
      logoTextShow: true,
      user:{
        id:"",
        name:"",
        avatar:"",
      },
    }
  },
  created() {
    this.getUser()
  },
  components: {
    Header,
    Aside,
  },
  methods:{
    collapse() {// 点击收缩按钮触发
      this.isCollapse = !this.isCollapse
      if (this.isCollapse) {  // 收缩
        this.sideWidth = 64
        this.collapseBtnClass = 'el-icon-s-unfold'
        this.logoTextShow = false
      } else {   // 展开
        this.sideWidth = 210
        this.collapseBtnClass = 'el-icon-s-fold'
        this.logoTextShow = true
      }
    },
    getUser() {
      this.request.get("/user/username").then(res => {
        console.log("------mange>"+res)
        this.user = res.data.data
      })
    },
  },
}
</script>

